// 一个返回当前日期指定格式的函数  如 2022-10-22 15:05:34   2022/10/22 15:05:34

function getTime(){
    let time=new Date();  //获取当前日期
    let year:number=time.getFullYear();   
    let month:any=time.getMonth()+1;
    let day:any=time.getDate();
    let hour:any=time.getHours();
    let mintues:any=time.getMinutes();
    let seconds:any=time.getSeconds();

    month > 9 ? month=month : month=`0${month}`     //月不足10，补0 
    day > 9 ? day=day : day=`0${day}`
    mintues > 9 ? mintues=mintues : mintues=`0${mintues}`
    seconds > 9 ? seconds=seconds : seconds='0'+seconds
    
    let result=`${year}-${month}-${day} ${hour}:${mintues}:${seconds}`;
    // let result=`${year}/${month}/${day} ${hour}:${mintues}:${seconds}`;  
    return result; 
}

function getSelectTime(selectTime:any){
    let time=new Date(selectTime);  //获取当前日期
    let year:number=time.getFullYear();   
    let month:any=time.getMonth()+1;
    let day:any=time.getDate();
    let hour:any=time.getHours();
    let mintues:any=time.getMinutes();
    let seconds:any=time.getSeconds();

    month > 9 ? month=month : month=`0${month}`     //月不足10，补0 
    day > 9 ? day=day : day=`0${day}`
    mintues > 9 ? mintues=mintues : mintues=`0${mintues}`
    seconds > 9 ? seconds=seconds : seconds='0'+seconds
    
    let result=`${year}-${month}-${day} ${hour}:${mintues}:${seconds}`;
    // let result=`${year}/${month}/${day} ${hour}:${mintues}:${seconds}`;  
    return result; 
}


export {
    getTime,
    getSelectTime
}